package formula.web;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import org.slf4j.LoggerFactory;

@SuppressWarnings("serial")
@ManagedBean
@ViewScoped
public class TeamsView implements Serializable {

	private final org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());

	@ManagedProperty(value = TeamHome.EL_NAME)
	TeamHome teamHome;
	@ManagedProperty(value = TeamsHome.EL_NAME)
	TeamsHome teamsHome;
	private boolean editMode = false;

	public void cancelEditTeam() {
		teamHome.clear();
		this.editMode = false;
	}

	public void deleteTeam() {
		teamHome.doDelete();
		teamsHome.clear();
		this.editMode = false;
	}

	public void updateTeam() {
		teamHome.doMerge();
		teamsHome.clear();
		this.editMode = false;
	}

	public void editNewTeam() {
		teamHome.clear();
		this.editMode = true;
	}

	public void setEditTeamById(Long _teamId) {
		teamHome.setTeamId(_teamId);
		editMode = true;
	}

	// then below : simple setters and getters
	public void setTeamHome(TeamHome _teamHome) {
		this.teamHome = _teamHome;
	}

	public boolean isEditMode() {
		return editMode;
	}

	public void setEditMode(boolean _editMode) {
		editMode = _editMode;
	}

	public void setTeamsHome(TeamsHome _teamsHome) {
		teamsHome = _teamsHome;
	}
}
